package com.markus.code.exam.jd;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Author:markusZhang
 * Date:Create in 2020/9/17 19:58
 * todo:
 */
public class Main {
    static boolean isNumber(char c) {
        if (c >= '0' && c <= '9') {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str2 = scanner.nextLine();
        String str = str2.replaceAll(" ","");
        ArrayList list = new ArrayList();
        boolean bl = true;
        for (int i = 0; i < str.length(); i++) {
            if (i + 3 < str.length() && isNumber(str.charAt(i)) && isNumber(str.charAt(i + 1))
                    && isNumber(str.charAt(i + 2)) && isNumber(str.charAt(i + 3))) {
                int ans = (str.charAt(i) - '0') * 1000 + (str.charAt(i + 1) - '0') * 100 +
                        (str.charAt(i + 2) - '0') * 10 + (str.charAt(i + 3) - '0');
                if (i > 0 && isNumber(str.charAt(i - 1))) {
                    bl = false;
                }
                if (i + 4 < str.length() && isNumber(str.charAt(i + 4))) {
                    bl = false;
                }
                if (ans < 1000 || ans > 3999) {
                    bl = false;
                }
                if (bl) {
                    list.add(ans);
                }
                bl = true;
            } else {
                continue;
            }
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i).toString()+" ");
        }
    }
}